<%@page import="javax.portlet.PortletPreferences"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.liferay.util.PwdGenerator"%>
<%@page import="it.apuliait.service.DocumentoLocalServiceUtil"%>
<%@page import="it.apuliait.model.LineaFattura"%>
<%@page import="it.apuliait.model.Documento"%>
<%@page import="javax.portlet.PortletURL"%>
<%@page import="javax.portlet.ActionRequest"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>

<script type="text/javascript" src="<%= request.getContextPath() %>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/js/jquery.ui.core.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/js/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/js/ui.datepicker-it.js"></script>
<link href="<%= request.getContextPath() %>/css/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/ui.datepicker.css" rel="stylesheet" type="text/css" />

<portlet:defineObjects />

<% 
String uploadProgressId = PwdGenerator.getPassword(PwdGenerator.KEY3, 4);
PortletPreferences prefs = renderRequest.getPreferences();

List<Documento> list_documento = (List<Documento>)renderRequest.getAttribute("list_documento");
String trasmittenteId = (String)renderRequest.getAttribute("trasmittenteId");
PortletURL iteratorURL = renderResponse.createRenderURL();
List<Documento> displayList = new ArrayList<Documento>();
pageContext.setAttribute("list_documento", list_documento);
%>

<p><b>TRASMETTI FILE</b></p>

<portlet:actionURL var="editCaseURL" name="uploadDocumentoFirmato">
<portlet:param name="trasmittenteId" value="<%= trasmittenteId %>" />
</portlet:actionURL>
<liferay-ui:success key="success" message=" YEAH. Case uploaded successfully!" />
<liferay-ui:error key="error"
    message="Sorry, an error prevented the upload. Please try again." />
    <liferay-ui:upload-progress
    id="<%= uploadProgressId %>"
    message="uploading"
    redirect="<%= editCaseURL %>"
  />

<aui:form action="<%= editCaseURL %>" enctype="multipart/form-data" method="post" >
<aui:input type="file" name="fileName" size="100"/>
<input type="submit" value="<liferay-ui:message key="upload" />" onClick="<%= uploadProgressId %>.startProgress(); return true;"/>
<!--  aui:button type="submit" value="Save" /-->
</aui:form>

<br />


<liferay-ui:search-container delta="10" emptyResultsMessage="Nessun Documento Trasmesso" iteratorURL="<%= iteratorURL %>" >
	<%
	
	if(list_documento!=null && list_documento.size()>0 ){	  
		displayList = list_documento.subList(searchContainer.getStart(), list_documento.size());
	}
	if( searchContainer.getEnd() < list_documento.size()){
		displayList=list_documento.subList(searchContainer.getStart(), searchContainer.getEnd());
	}
	
	pageContext.setAttribute("displayList", displayList);
	
	%>
	<liferay-ui:search-container-results results="<%= displayList %>" total="<%= list_documento.size() %>" />
	     <liferay-ui:search-container-row className="it.apuliait.model.Documento" keyProperty="documentoId" modelVar="documento" >
	       
			<liferay-ui:search-container-column-text name="Dati Pagamento" >
       		 	<p align="center">DATO</p> 
       		</liferay-ui:search-container-column-text>
	    	
	    </liferay-ui:search-container-row>
	    <liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
	</liferay-ui:search-container>